package ln.javatest.day07.demo01;
/*
如果一个成员变量使用了static关键字，那么这个变量不再属于对象自己，而是属于所在的类。多个对象共享同一份数据
*/

public class Demo01StaticField {
    public static void main(String[] args) {
        Student one = new Student("王嘉尔",25);
        //因为在Student类中room用static关键字修饰了，所以多个对象共享同一份数据。
        one.room = "101教室";
        Student two = new Student("易烊千玺",21);
        System.out.println("姓名：" + one.getName() + ",年龄: " + one.getAge() + ",教室是：" + Student.room + ",学号是：" + one.getId());
        System.out.println("姓名：" + two.getName() + ",年龄: " + two.getAge() + ",教室是：" + Student.room + ",学号是：" + two.getId());
    }
}
